import { SupportedDbtAdapter } from '../types/dbt';
import { type Explore } from '../types/explore';
import { DimensionType, FieldType, MetricType } from '../types/field';

export const mockOrdersExplore: Explore = {
    name: 'orders',
    label: 'Orders',
    tags: [],
    baseTable: 'orders',
    targetDatabase: SupportedDbtAdapter.POSTGRES,
    tables: {
        orders: {
            name: 'orders',
            label: 'Orders',
            database: 'test',
            schema: 'public',
            sqlTable: 'orders',
            lineageGraph: {},
            dimensions: {
                order_date_year: {
                    name: 'order_date_year',
                    label: 'Order Date Year',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date_year',
                    tablesReferences: [],
                    sql: 'order_date_year',
                    hidden: false,
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'order_date',
                },
                order_date_month: {
                    name: 'order_date_month',
                    label: '',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date_month',
                    tablesReferences: [],
                    sql: 'order_date_month',
                    hidden: false,
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'order_date',
                },
                order_date_week: {
                    name: 'order_date_week',
                    label: 'Order Date Week',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'order_date_week',
                    sql: 'order_date_week',
                    hidden: false,
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'order_date',
                },
                status: {
                    name: 'status',
                    label: 'Status',
                    description: 'Status of the order',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'status',
                    sql: 'status',
                    hidden: false,
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.BOOLEAN,
                },
            },
            metrics: {
                total_orders: {
                    name: 'total_orders',
                    label: 'Total Orders',
                    table: 'orders',
                    tableLabel: 'Orders',
                    compiledSql: 'total_orders',
                    tablesReferences: [],
                    fieldType: FieldType.METRIC,
                    type: MetricType.COUNT,
                    sql: 'total_orders',
                    hidden: false,
                    description: 'Total orders',
                },
            },
        },
        customers: {
            name: 'customers',
            label: 'Customers',
            database: 'test',
            schema: 'public',
            sqlTable: 'customers',
            metrics: {},
            lineageGraph: {},
            dimensions: {
                id: {
                    name: 'id',
                    label: 'ID',
                    table: 'customers',
                    tableLabel: 'Customers',
                    compiledSql: 'id',
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.STRING,
                    sql: 'id',
                    hidden: false,
                },
                created_at_week: {
                    name: 'created_at_week',
                    label: 'Created At Week',
                    table: 'customers',
                    tableLabel: 'Customers',
                    compiledSql: 'created_at_week',
                    sql: 'created_at_week',
                    hidden: false,
                    tablesReferences: [],
                    fieldType: FieldType.DIMENSION,
                    type: DimensionType.DATE,
                    timeIntervalBaseDimensionName: 'created_at',
                },
            },
        },
    },
    joinedTables: [
        {
            table: 'customers',
            sqlOn: '${orders.customer_id} = ${customers.id}',
            compiledSqlOn: '(orders.customer_id) = (customers.id)',
            type: undefined,
        },
    ],
};

export const mockCustomersExplore: Explore = {
    name: 'customers',
    label: 'Customers',
    tags: [],
    baseTable: 'customers',
    targetDatabase: SupportedDbtAdapter.POSTGRES,
    joinedTables: [],
    tables: {
        customers: {
            ...mockOrdersExplore.tables.customers,
        },
    },
};
